/*
* 专业热度top10
* */

(function rktop10() {
    // 实例化对象
    var myChart = echarts.init(document.querySelector(".rk .chart"));
    // 指定配置和数据
    var option = {
        color: ["#00f2f1", "#ed3f35", "#7171C6"],
        tooltip: {
            trigger: "axis",
            axisPointer: {
                // 坐标轴指示器，坐标轴触发有效
                type: "shadow" // 默认为直线，可选为：'line' | 'shadow'
            }
        },
        grid: {
            left: "0%",
            top: "10px",
            right: "0%",
            bottom: "4%",
            containLabel: true
        },
        yAxis: [
            {
                data: [],
                type: "category",
                axisTick: {
                    alignWithLabel: true
                },
                axisLabel: {
                    textStyle: {
                        color: "rgba(255,255,255)",
                        fontSize: "10"
                    }
                },
                axisLine: {
                    show: false
                }
            }
        ],
        xAxis: [
            {
                type: "value",
                axisLabel: {
                    show: true,
                    color: "rgba(255,255,255,.7)",
                    fontSize:"10",
                    formatter: function (value) {
                        if (value >= 1000) {
                            value = value / 10000 + 'w';
                        }
                        return value;
                    },
                },
                axisLine: {
                    lineStyle: {
                        color: "rgba(255,255,255,.1)"
                        // width: 1,
                        // type: "solid"
                    }
                },
                splitLine: {
                    lineStyle: {
                        color: "rgba(255,255,255,.1)"
                    }
                }
            }
        ],
        series: [{
            type: 'bar',
            barWidth: "35%",
            smooth: true,
            itemStyle: {
                color: "#1089E7",
                barBorderRadius: 6
            },
            name: "软科排名",
            data: []
        }]

    };
    $.ajax({
        url: 'http://localhost:8080/rank/data1',
        type: 'get',
        dataType: 'json',
        success: function (res) {
            var name = [];
            var rank = [];
            // var results = []
            for (let i = 0; i < res.length; i++) {
                name[i] = res[i]["name"]
                rank[i] = res[i]["rank"]

                // results.push({name: time[i], value: grade1[i]})
            }
            console.log(name);
            option.yAxis[0].data = name;
            option.series[0].data = rank;
            myChart.setOption(option);
        }
    });


    // option.xAxis[0].data = time;
    // option.series[0].data = grade;
    // // 把配置给实例对象
    myChart.setOption(option);
    window.addEventListener("resize", function () {
        myChart.resize();
    })
}) ();


(function xyhtop10() {
    // 实例化对象
    var myChart = echarts.init(document.querySelector(".xyh .chart"));
    // 指定配置和数据
    var option = {
        color: ["#00f2f1", "#ed3f35", "#7171C6"],
        tooltip: {
            trigger: "axis",
            axisPointer: {
                // 坐标轴指示器，坐标轴触发有效
                type: "shadow" // 默认为直线，可选为：'line' | 'shadow'
            }
        },
        grid: {
            left: "0%",
            top: "10px",
            right: "0%",
            bottom: "4%",
            containLabel: true
        },
        yAxis: [
            {
                data: [],
                type: "category",
                axisTick: {
                    alignWithLabel: true
                },
                axisLabel: {
                    textStyle: {
                        color: "rgba(255,255,255)",
                        fontSize: "10"
                    }
                },
                axisLine: {
                    show: false
                }
            }
        ],
        xAxis: [
            {
                type: "value",
                axisLabel: {
                    show: true,
                    color: "rgba(255,255,255,.7)",
                    fontSize:"10",
                    formatter: function (value) {
                        if (value >= 1000) {
                            value = value / 10000 + 'w';
                        }
                        return value;
                    },
                },
                axisLine: {
                    lineStyle: {
                        color: "rgba(255,255,255,.1)"
                        // width: 1,
                        // type: "solid"
                    }
                },
                splitLine: {
                    lineStyle: {
                        color: "rgba(255,255,255,.1)"
                    }
                }
            }
        ],
        series: [{
            type: 'bar',
            barWidth: "35%",
            smooth: true,
            itemStyle: {
                color: "#1089E7",
                barBorderRadius: 6
            },
            name: "软科排名",
            data: []
        }]

    };
    $.ajax({
        url: 'http://localhost:8080/xyh/data1',
        type: 'get',
        dataType: 'json',
        success: function (res) {
            var name = [];
            var rank = [];
            // var results = []
            for (let i = 0; i < res.length; i++) {
                name[i] = res[i]["name"]
                rank[i] = res[i]["rank"]

                // results.push({name: time[i], value: grade1[i]})
            }
            console.log(name);
            option.yAxis[0].data = name;
            option.series[0].data = rank;
            myChart.setOption(option);
        }
    });
    // option.xAxis[0].data = time;
    // option.series[0].data = grade;
    // // 把配置给实例对象
    myChart.setOption(option);
    window.addEventListener("resize", function () {
        myChart.resize();
    })
}) ();


/*
* 校友会排名第一校园指数
* */
(function xyhTop1() {
    var myChart = echarts.init(document.querySelector(".piexyh .chart"));
    var option = {
        title:{
            text:'',
            left:"center"
        },
        series: [
            {
                type:'pie',
                center: ['10%', '27%'],
                radius: ['50%', '40%'],
                itemStyle:{
                    color:"#669966"
                },
                label: {
                    normal: {
                        show: true,
                        position: 'center',
                        formatter: "{b|{b}}\n{b|{c}}",
                        rich: {
                            b: {
                                fontSize:16,
                                lineHeight: 20,
                                align: 'center'
                            },
                        }
                    },
                    emphasis: {
                        show: true,
                        textStyle: {
                            fontSize: '14',
                        }
                    }
                },
                data:[
                    //图一
                ]
            },
            {
                type:'pie',
                center: ['35%', '60%'],
                radius: ['50%', '58%'],
                itemStyle:{
                    color:"#199ED8"
                },
                label: {
                    normal: {
                        show: true,
                        position: 'center',
                        formatter: "{b|{b}}\n{b|{c}}",
                        rich: {
                            b: {
                                fontSize:16,
                                fontWeight:"bold",
                                lineHeight: 20,
                                align: 'center'
                            },
                        }
                    },
                    emphasis: {
                        show: true,
                        textStyle: {
                            fontSize: '14',
                        }
                    }
                },
                data:[
                ]
            },
            {
                type:'pie',
                center: ['65%', '60%'],
                radius: ['50%', '58%'],
                itemStyle:{
                    color:"#199ED8"
                },
                label: {
                    normal: {
                        show: true,
                        position: 'center',
                        formatter: "{b|{b}}\n{b|{c}}",
                        rich: {
                            b: {
                                fontSize:14,
                                lineHeight: 20,
                                align: 'center'
                            },
                        }
                    },
                    emphasis: {
                        show: true,
                        textStyle: {
                            fontSize: '14',
                        }
                    }
                },
                data:[
                ]
            },
            {
                type:'pie',
                center: ['90%', '31%'],
                radius: ['50%', '40%'],
                itemStyle:{
                    color:"#FF9966"
                },
                label: {
                    normal: {
                        show: true,
                        position: 'center',
                        formatter: "{b|{b}}\n{b|{c}}",
                        rich: {
                            b: {
                                fontSize:14,
                                lineHeight: 20,
                                align: 'center'
                            },
                        }
                    },
                    emphasis: {
                        show: true,
                        textStyle: {
                            fontSize: '14',
                        }
                    }
                },
                data:[
                ]
            }
        ]
    };
    $.ajax({
        url: 'http://localhost:8080/rank/xyhtop1',
        type: 'get',
        dataType: 'json',
        success: function (res) {
            var stu = [];
            var life = [];
            var jiuye = [];
            var zh = [];
            var name = [];
            var results1 = []
            var results2 = []
            var results3 = []
            var results4 = []
            for (let i = 0; i < res.length; i++) {
                stu[i] = res[i]["stu"]
                life[i] = res[i]["life"]
                jiuye[i] = res[i]["jiuye"]
                zh[i] = res[i]["zh"]
                name[i] = res[i]["name"]
                results1.push({value: stu[i], name: '学习指数'})
                results2.push({value: life[i], name: '生活指数'})
                results3.push({value: jiuye[i], name: '就业指数'})
                results4.push({value: zh[i], name: '综合评分'})

            }
            console.log(name);
            option.title.text = name;
            option.series[0].data = results1;
            option.series[1].data = results2;
            option.series[2].data = results3;
            option.series[3].data = results4;
            myChart.setOption(option);
        }
    });

    myChart.setOption(option);
    window.addEventListener("resize", function () {
        myChart.resize();
    })
}) ();




/*
* 软科排名第一校园指数
* */
(function rkTop1() {
   var myChart = echarts.init(document.querySelector(".pierk .chart"));
    var option = {
        title:{
            text:'diyu',
            left:"center"
        },
        series: [
            {
                type:'pie',
                center: ['10%', '27%'],
                radius: ['50%', '40%'],
                itemStyle:{
                    color:"#669966"
                },
                label: {
                    normal: {
                        show: true,
                        position: 'center',
                        formatter: "{b|{b}}\n{b|{c}}",
                        rich: {
                            b: {
                                fontSize:16,
                                lineHeight: 20,
                                align: 'center'
                            },
                        }
                    },
                    emphasis: {
                        show: true,
                        textStyle: {
                            fontSize: '14',
                        }
                    }
                },
                data:[
                    //图一
                ]
            },
            {
                type:'pie',
                center: ['35%', '60%'],
                radius: ['50%', '58%'],
                itemStyle:{
                    color:"#199ED8"
                },
                label: {
                    normal: {
                        show: true,
                        position: 'center',
                        formatter: "{b|{b}}\n{b|{c}}",
                        rich: {
                            b: {
                                fontSize:16,
                                fontWeight:"bold",
                                lineHeight: 20,
                                align: 'center'
                            },
                        }
                    },
                    emphasis: {
                        show: true,
                        textStyle: {
                            fontSize: '14',
                        }
                    }
                },
                data:[
                ]
            },
            {
                type:'pie',
                center: ['65%', '60%'],
                radius: ['50%', '58%'],
                itemStyle:{
                    color:"#199ED8"
                },
                label: {
                    normal: {
                        show: true,
                        position: 'center',
                        formatter: "{b|{b}}\n{b|{c}}",
                        rich: {
                            b: {
                                fontSize:14,
                                lineHeight: 20,
                                align: 'center'
                            },
                        }
                    },
                    emphasis: {
                        show: true,
                        textStyle: {
                            fontSize: '14',
                        }
                    }
                },
                data:[
                ]
            },
            {
                type:'pie',
                center: ['90%', '31%'],
                radius: ['50%', '40%'],
                itemStyle:{
                    color:"#FF9966"
                },
                label: {
                    normal: {
                        show: true,
                        position: 'center',
                        formatter: "{b|{b}}\n{b|{c}}",
                        rich: {
                            b: {
                                fontSize:14,
                                lineHeight: 20,
                                align: 'center'
                            },
                        }
                    },
                    emphasis: {
                        show: true,
                        textStyle: {
                            fontSize: '14',
                        }
                    }
                },
                data:[
                ]
            }
        ]
    };
    $.ajax({
        url: 'http://localhost:8080/rank/top1',
        type: 'get',
        dataType: 'json',
        success: function (res) {
            var stu = [];
            var life = [];
            var jiuye = [];
            var zh = [];
            var name = [];
            var results1 = []
            var results2 = []
            var results3 = []
            var results4 = []
            for (let i = 0; i < res.length; i++) {
                stu[i] = res[i]["stu"]
                life[i] = res[i]["life"]
                jiuye[i] = res[i]["jiuye"]
                zh[i] = res[i]["zh"]
                name[i] = res[i]["name"]
                results1.push({value: stu[i], name: '学习指数'})
                results2.push({value: life[i], name: '生活指数'})
                results3.push({value: jiuye[i], name: '就业指数'})
                results4.push({value: zh[i], name: '综合评分'})

            }
            console.log(results1);
            option.series[0].data = results1;
            option.title.text = name;
            option.series[1].data = results2;
            option.series[2].data = results3;
            option.series[3].data = results4;
            myChart.setOption(option);
        }
    });

    myChart.setOption(option);
    window.addEventListener("resize", function () {
        myChart.resize();
    })
}) ();



